<template>
  <div @click="clickLove">
    <van-icon class="love-praise-icon" :class="love ? 'red' : ''" :name="love ? 'good-job' : 'good-job-o'"/>
    <span class="praise-num" style="margin-left: 5px;">{{loveNum}}</span>
  </div>
</template>

<script>
export default {
  name: "LoveIndex",
  data() {
    return {
      loveNum: 0,
      love: false
    }
  },
  created() {
    this.loveNum = Math.round(Math.random() * 100);
  },
  methods: {
    clickLove() {
      this.love = !this.love;
      if (this.love) {
        this.loveNum ++;
      } else {
        this.loveNum --;
      }
    }
  }
}
</script>

<style scoped>
.red {
  color: red;
}
</style>
